package com.kili.mirco.spark_als.spark;

import com.kili.mirco.spark_als.ref.Processor;
import org.apache.spark.api.java.function.Function;
import org.apache.spark.mllib.recommendation.Rating;
import org.springframework.util.ClassUtils;

import java.util.Iterator;
import java.util.ServiceLoader;
import java.util.regex.Pattern;

/**
 * @date 19-6-1
 * @auther jackliang
 * @description TODO
 */
public class ParseRating implements Function<String, Rating> {

    private static final Pattern COMMA = Pattern.compile(",");

    @Override
    public Rating call(String line) {
        String[] tok = COMMA.split(line);
        int x = Integer.parseInt(tok[0]);
        int y = Integer.parseInt(tok[1]);
        double rating = Double.parseDouble(tok[2]);
        return new Rating(x, y, rating);
    }
}
